// write your code here
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int n = sc.nextInt();
            if(n == 0){
                break;
            }
            int res = 0;
            int count = 0;
            for(int i=1,j=1;i<Integer.MAX_VALUE;i = j*5,j++){
                if((4*i+1)%5==0){
                    count++;
                }
                if(count == n){
                    res = i;
                    break;
                }
            }
            int total = res * 4 + 1;

        }
    }
}